package com.czxy.changgou4.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.czxy.changgou4.pojo.Brand;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
@Mapper
public interface BrandMapper extends BaseMapper<Brand> {
    /**
     * 通过分类id查询所有的品牌
     * @param cid
     * @return
     */
    @Select("SELECT * FROM tb_brand b " +
            "INNER JOIN tb_category_brand cb ON b.id = cb.brand_id " +
            "WHERE cb.category_id = #{cid}")
    public List<Brand> selectAllByCategoryId(@Param("cid") Integer cid);
}
